<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>自动登录 - {$siteConfig.siteName}</title>
    <meta name="keywords" content="{$siteConfig.siteKeyword}"/>
    <meta name="description" content="{$siteConfig.siteDesc}"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="{$siteConfig.favicon}" type="image/x-icon" rel="shortcut icon"/>

    {php} if(\think\App::$debug){ {/php}
    <!-- 调试窗口 -->
    <script src="__JS__/vconsole/vconsole.min.js" charset="utf-8"></script>
    <script>
        // 调试窗口初始化
        new VConsole();
    </script>
    {php} } {/php}

    {if condition="isset($env) && $env.dingMobile"}
    <script src="https://g.alicdn.com/dingding/open-develop/1.6.9/dingtalk.js"></script>
    <script>
        var d = dd;
    </script>
    {elseif condition="isset($env) && $env.dingPc"/}
    <script src="https://g.alicdn.com/dingding/dingtalk-pc-api/2.7.0/index.js"></script>
    <script>
        var d = DingTalkPC;
    </script>
    {/if}

    <script>
        var jsapiConfig = {$jsapiConfigJson};
        if (d) {
            d.config(jsapiConfig);
            d.error(function (error) {
                d.device.notification.alert({
                    message: error.message || error.errorMessage,
                    title: "jsapi错误提示",
                    buttonName: "确定",
                    onSuccess: function () {
                        document.location.href = document.location.href + "&scan=true";
                    },
                    onFail: function (err) {
                        console.error(err);
                    }
                });
            });
        }
    </script>
</head>

<body class="layui-layout-body" style="overflow: auto;">

<script>
    d.ready(function () {
        d.runtime.permission.requestAuthCode({
            corpId: "{$corpid}",
            onSuccess: function (result) {
                document.location.href = '/core/enterprise.user/dingCodeAuth?eid={$eid}&code=' + result['code'];
            },
            onFail: function (err) {
                d.device.notification.alert({
                    message: err.message || err.errorMessage,
                    title: "获取用户信息失败",
                    buttonName: "确定",
                    onSuccess: function () {
                        document.location.href = document.location.href + "&scan=true";
                    },
                    onFail: function (err) {
                        console.error(err);
                    }
                });
            }
        });
    });
</script>

<style>
    .login-container {
        text-align: center;
        margin: 0 auto;
        margin-top: 35vh;
    }

    .login-container .text {
        font-size: 1.5em;
    }
</style>

<div class="login-container">
    <img src="__IMAGES__/loading.svg"/>
    <div class="text">自动登录中...</div>
</div>
</body>
</html>